package com.cw.subject.infra.basic.service.impl;

import com.cw.subject.infra.basic.entity.SubjectMultiplePO;
import com.cw.subject.infra.basic.mapper.SubjectMultiplePODao;
import com.cw.subject.infra.basic.service.SubjectMultiplePOService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 多选题信息表(SubjectMultiplePO)表服务实现类
 *
 * @author makejava
 * @since 2024-04-11 15:31:56
 */
@Service("subjectMultipleService")
public class SubjectMultiplePOServiceImpl implements SubjectMultiplePOService {
    @Resource
    private SubjectMultiplePODao subjectMultiplePODao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SubjectMultiplePO queryById(Integer id) {
        return this.subjectMultiplePODao.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param subjectMultiplePO 实例对象
     * @return 实例对象
     */
    @Override
    public SubjectMultiplePO insert(SubjectMultiplePO subjectMultiplePO) {
        this.subjectMultiplePODao.insert(subjectMultiplePO);
        return subjectMultiplePO;
    }

    /**
     * 修改数据
     *
     * @param subjectMultiplePO 实例对象
     * @return 实例对象
     */
    @Override
    public SubjectMultiplePO update(SubjectMultiplePO subjectMultiplePO) {
        this.subjectMultiplePODao.update(subjectMultiplePO);
        return this.queryById(subjectMultiplePO.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.subjectMultiplePODao.deleteById(id) > 0;
    }

    /**
     * @author: 江传文
     * @date: 2024/4/14 14:29
     * 批量插入
     */
    @Override
    public void batchInsert(List<SubjectMultiplePO> subjectMultipleList) {
        this.subjectMultiplePODao.insertBatch(subjectMultipleList);
    }

    /**
     * @author: 江传文
     * @date: 2024/4/14 14:29
     * 条件查询
     */
    @Override
    public List<SubjectMultiplePO> queryByCondition(SubjectMultiplePO subjectMultiplePO) {
        return this.subjectMultiplePODao.queryAllByLimit(subjectMultiplePO);
    }
}
